<template>
  <el-dialog
    title="详情"
    :close-on-click-modal="false"
    append-to-body
    :visible.sync="visible"
    class="jsbos-dialog jsbos-dialog_center"
    lock-scroll
    width="600px"
  >
    <el-row :gutter="15" class="">
      <el-form
        ref="elForm"
        :model="dataForm"
        size="small"
        label-width="100px"
        label-position="right"
      >
        <template v-if="!loading">
          <el-col :span="24">
            <el-form-item label="试卷目录id" prop="categoryId">
              <p>
                {{ dataForm.categoryId | dynamicTreeText(categoryIdOptions) }}
              </p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="编码" prop="enCode">
              <p>{{ dataForm.enCode }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="名称" prop="fullName">
              <p>{{ dataForm.fullName }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="试卷介绍" prop="intro">
              <p>{{ dataForm.intro }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="试卷类型" prop="paperType">
              <p>{{ dataForm.paperType | dynamicText(paperTypeOptions) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="随机试卷" prop="paperrandomVersion">
              <p>
                {{
                  dataForm.paperrandomVersion
                    | dynamicText(paperrandomVersionOptions)
                }}
              </p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="随机试卷" prop="openDifficultyGrade">
              <p>{{ dataForm.openDifficultyGrade }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="随机试题" prop="folders">
              <p>{{ dataForm.folders }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label-width="0">
              <div class="jsbos-common-title">
                <h2>设置分值</h2>
              </div>
              <el-table :data="dataForm.temsexampaperruleList" size="mini">
                <el-table-column
                  type="index"
                  width="50"
                  label="序号"
                  :align="'center'"
                />
                <el-table-column prop="paperId" label="试卷id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.paperId }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="folderId" label="题库id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.folderId }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="questionType" label="题型">
                  <template slot-scope="scope">
                    <p>{{ scope.row.questionType }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="difficultyGradeId" label="试题等级id">
                  <template slot-scope="scope">
                    <p>
                      {{
                        scope.row.difficultyGradeId
                          | dynamicText(difficultyGradeIdOptions)
                      }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="questionNum" label="试题数量">
                  <template slot-scope="scope">
                    <p>{{ scope.row.questionNum }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="score" label="分值设置">
                  <template slot-scope="scope">
                    <p>{{ scope.row.score }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="missedScore" label="漏选给分">
                  <template slot-scope="scope">
                    <p>{{ scope.row.missedScore }}</p>
                  </template>
                </el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label-width="0">
              <div class="jsbos-common-title">
                <h2>固定试题</h2>
              </div>
              <el-table :data="dataForm.temsexampaperquestionList" size="mini">
                <el-table-column
                  type="index"
                  width="50"
                  label="序号"
                  :align="'center'"
                />
                <el-table-column prop="paperId" label="试卷id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.paperId }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="questionId" label="试题id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.questionId }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="score" label="分值设置">
                  <template slot-scope="scope">
                    <p>{{ scope.row.score }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="missedScore" label="漏选给分">
                  <template slot-scope="scope">
                    <p>{{ scope.row.missedScore }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="scoreType" label="评分规则(填空题)">
                  <template slot-scope="scope">
                    <p>
                      {{ scope.row.scoreType | dynamicText(scoreTypeOptions) }}
                    </p>
                  </template>
                </el-table-column>
                <!-- <el-table-column
                  prop="subQuestionScoreRule"
                  label="评分规则(案例题)"
                >
                  <template slot-scope="scope">
                    <p>
                      {{
                        scope.row.subQuestionScoreRule
                          | dynamicText(subQuestionScoreRuleOptions)
                      }}
                    </p>
                  </template>
                </el-table-column> -->
              </el-table>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="及格线(%)" prop="passLine">
              <p>{{ dataForm.passLine }}</p>
            </el-form-item>
          </el-col>
        </template>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false"> 取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getDetail } from "@/views/exam/api/paper";
export default {
  components: {},
  props: {
    categoryIdOptions: {
      type: Array,
      default: [],
    },
    categoryIdProps: {
      type: Object,
      default: {
        children: "children",
        label: "fullName",
        value: "id",
      },
    },
  },
  data() {
    return {
      visible: false,
      loading: false,
      printId: "",
      dataForm: {
        id: "",
        categoryId: "",
        enCode: "",
        fullName: "",
        intro: "",
        paperType: "1",
        paperrandomVersion: "2",
        openDifficultyGrade: 0,
        folders: "",
        passLine: 60,
        description: "",
        enabledMark: 1,
        creatorUserId: "",
        creatorTime: "",
        lastModifyUserId: "",
        lastModifyTime: "",
        deleteTime: "",
        deleteUserId: "",
        deleteMark: 0,
        temsexampaperruleList: [],
        temsexampaperquestionList: [],
      },
      categoryIdOptions: [
        {
          children: [{ fullName: "选项1-1", id: "2" }],
          fullName: "选项1",
          id: "1",
        },
      ],
      categoryIdProps: { children: "children", label: "fullName", value: "id" },
      paperTypeOptions: [
        { fullName: "固定试卷", id: "1" },
        { fullName: "随机试卷", id: "2" },
      ],
      paperrandomVersionOptions: [
        { fullName: "固定版本", id: "1" },
        { fullName: "随机版本", id: "2" },
      ],

      difficultyGradeIdOptions: [],
      scoreTypeOptions: [
        { fullName: "空", id: "1" },
        { fullName: "题", id: "2" },
      ],
      subQuestionScoreRuleOptions: [
        { fullName: "整题", id: "1" },
        { fullName: "每小题", id: "2" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      for (let i = 0; i < _dataAll.temsexampaperruleList.length; i++) {
        var _list = _dataAll.temsexampaperruleList[i];
      }
      for (let i = 0; i < _dataAll.temsexampaperquestionList.length; i++) {
        var _list = _dataAll.temsexampaperquestionList[i];
      }
      this.dataForm = _dataAll;
    },

    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          getDetail(this.dataForm.id).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
  },
};
</script>
